package com.diqizu.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import com.diqizu.entity.ChanPininof;
import com.diqizu.entity.DisPlay;
import com.diqizu.entity.ProType;
import com.diqizu.utli.DBManager;
import com.diqizu.utli.QueryDataResult;
/**
 * 
 * @author DELL
 *
 */
public class ProDuctType {

  
  

  public ArrayList<ProType> type() {
    String sql ="select * from producttype";
    
    System.out.println("ִ执行的语句是"+sql);
    QueryDataResult execQuery = DBManager.execQuery(sql);
     ArrayList<ProType> list= new ArrayList<ProType>();
    if(execQuery!=null) {
      ResultSet rs=execQuery.rs;
      try {
        while(rs.next()) {
          ProType e1=new ProType(rs.getInt("typeId"),rs.getString("typeName"),rs.getString("productTypeId"));
          
          list.add(e1);  
        }
        }catch(SQLException e1){
          e1.printStackTrace();
          
          
        }finally {
          
          execQuery.close();
        }
      }
      System.out.println(list);
      return list;  
    }
  //添加
  public boolean insertprotype(ProType ProType) {
	  String sql="insert into producttype (typeId,typeName,productTypeId) values('"+ProType.getTypeId()+"','"+ProType.getTypeName()+"','"+ProType.getProductTypeId()+"')";
	  System.out.println("执行饿语句是"+sql);
	  return  DBManager.execUpdate(sql);
	  
  }
  
  //编辑
  //修改方法
  public boolean updateprotype(ProType ProType) {
		String sql ="update producttype set typeName='"+ProType.getTypeName()+"' where typeId='"+ProType.getTypeId()+"'";
		System.out.println("执行的语句是："+sql);
		return DBManager.execUpdate(sql);
	}

  
//删除
  public boolean deleteproduct(int typeId) {
		String sql ="delete from producttype where typeId ="+typeId;
		System.out.println("执行的语句是："+sql);
		return DBManager.execUpdate(sql);
  
  
  
  }
  
  
  
  
  
  
  
}
